package com.mes.sync;

import com.sun.jna.Callback;
import com.sun.jna.Library;
import com.sun.jna.Native;

public class KnitFlatCallbackFun {
	public interface JnaCallBackDll extends Library {

		public static JnaCallBackDll instance = (JnaCallBackDll) Native.loadLibrary("src/conf/knitFlatPri.dll", JnaCallBackDll.class);

		int RnKnit_Run();

		long RnKnit_Send(char type, String pMac, String pData, int nLen, int dwSeq);

		long RnKnit_SetReceiveFun(TRnKnit_ReceiveImpl pFun);

		public interface TRnKnit_Receive extends Callback {
			public void TRnKnit_Receive(char cType, String pMac, String pData, int nLen, int dwSeq);
		}

		public static class TRnKnit_ReceiveImpl implements TRnKnit_Receive {
			public void TRnKnit_Receive(char cType, String pMac, String data, int nLen, int dwSeq) {
				System.out.println("回调成功！");
			}
		}
	}

	public static void main(String[] args) {
		int runResult = JnaCallBackDll.instance.RnKnit_Run();
		System.out.println("启动服务结果：" + runResult);

		String str = "{\"at\":1547088782207,\"type\":2,\"dev_id\":\"3030303030303030BAEF303030303232\",\"status\":1}";

		long sendResult = JnaCallBackDll.instance.RnKnit_Send('1',
				"3030303030303030BAEF303030303232", str, str.length(), 1);
		System.out.println("请求结果：" + sendResult);
	}
}